<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>微信登录回调</title>
    <script src="js/vue.js"></script>
    <script src="js/axios.js"></script>
    <script src="js/common.js"></script>
</head>
<body>
    <div id="app">

    </div>
</body>
<script type="application/javascript">
    new Vue({
        el: "#app",
        data: {
        },
        methods: {
        },
        mounted() {
            var url = location.href
            let map =  parseUrlParams2Obj(url)
            //我们不能直接在这里发送请求  要使用后台去发送请求  这样才不会泄露我们的密钥
            this.$http.get("/wechat/login/"+map.code).then(res =>{
                alert(1111)
                if(res.data.success){
                    //如果返回的是true  微信登录是成功的
                    localStorage.setItem("token",res.data.resultObj.token)
                    localStorage.setItem("user",JSON.stringify(res.data.resultObj.user))
                    location = "index.html";
                }else {//false
                    let openId = res.data.resultObj
                    location = "bind.html?openId="+openId;
                }
            })
        }
    })
</script>
</html>